import unittest
import logging

from odb.utils import logger

handler = logging.Handler()
handler.setLevel(logging.WARN)
logger.addHandler(handler)

port = 8800

def setUp(test):
    import threading
    from tornado.ioloop import IOLoop
    thread = test.thread = threading.Thread(target=IOLoop.instance().start)
    thread.start()
    import time
    while not thread.is_alive():
        time.sleep(0.1)

def tearDown(test):
    from tornado.ioloop import IOLoop
    IOLoop.instance().stop()
    test.thread.join()
    del test.thread

class BaseTestCase(unittest.TestCase):
    setUp = setUp
    tearDown = tearDown

